function initIndex() {
    $(function () {
        getTime();
        setInterval("getTime();", 60000);
        setInterval("breakFlowCount();getRemindView();", 600000);

        //获取天气
        var url = $('#watherUrl').val();
        $.get(url, function (res) {
            console.log(res)
            $('.fl .wt').text(res.type);
            var c = res.low + '-' + res.high;
            $('.fl .c').text(c);
            $('.box2 .iconfont').html('&#' + res.icon + ';');
            var html = '';
            for (var i = 0; i < res.after.length; i++) {
                html += '<li><div style="float:left"><i class="iconfont fl">&#' + res.after[i].icon + ';</i></div>';
                html += '<div style="float:left"><span>' + res.after[i].date + '</span>';
                html += '<span>' + res.after[i].type + '</span>';
                html += '<label>' + res.after[i].low + '-' + res.after[i].high + '</label>';
                html += '</div><p class="clear"></p></li>';
            }
            $('.dayInfo .after ul').html(html);
        })

        //登录企业邮箱
        var url = $('#loginEmail').val();
        $.get(url, function (res) {
            console.log(res)
            if (res !== false) {
                $('.newEmail').attr('href', res);
            }
        })

        //导航
        $(document).on("click", ".head .nav>li", function () {
            $(this).addClass("active").siblings().removeClass("active");
            var $index = $(this).index();
//                    $(".subNav ul").eq($index).show().siblings().hide();
        });
        //0627
        $("#stateBox>ul").height(window.innerHeight - 130);
        $(document).on("click", "#stateBox li>a", function () {
            var state = $(this).parents("li").attr("state");
            if (state == "hide") {
                $(this).parents("li").attr("state", "show");
                $(this).parents("li").addClass("item-show").removeClass("item-hide");
            } else if (state == "show") {
                $(this).parents("li").attr("state", "hide");
                $(this).parents("li").addClass("item-hide").removeClass("item-show");
                $('#stateBox ul').html(html)
            }
        })

        $(document).on("click", ".tabBox .navList li", function () {
            $(this).addClass("active").siblings().removeClass("active");
            var $index = $(this).index();
            $(this).parents(".tabBox").find(".list").eq($index).show().siblings().hide();
            var url = $(this).attr('data-url');
            $(this).parents('.tabBox').prev().find('a').attr('href', url);
        });

        //新闻tab
        $(document).on("click", "#newsBox span", function () {
            $(this).addClass("active").siblings().removeClass("active");
            var $index = $(this).index();
            $(this).parents(".section").find(".list").eq($index).show().siblings().hide();
            var url = $(this).attr('data-url');
            $('#newsBox a').attr('href', url);
        })
        //新闻轮播
        var mySwiper = new Swiper('.swiper-container', {
            loop: true,
            autoplay: 5000,
            //				pagination : '.pagination',
            pagination: '.pagination',
            paginationClickable: true,
        });
        //自助查询
        $(document).on("click", ".section9 .searchBox li", function () {
            var $index = $(this).index();
            $(this).parents(".searchBox").find(".inputWrap").eq($index).show().siblings(".inputWrap").hide();
        });
        $(document).on("click", ".page-index", function (e) {
            if (e.target.className != 'inputWrap inputWrap1' && e.target.className != 'txlSearch' && e.target.className != 'name submitEnter' && e.target.className != 'txlSearch' && e.target.className != "hysSearch" && e.target.className != "") {
                $(".section9 .searchBox").find(".inputWrap").hide();
            }
        })
        //回车查询
        $(document).on('input', '.submitEnter', function (e) {
            var oevent = this.id;
            $(this).off().on({
                oevent: function (e) {

                },
                compositionstart: function () {
//                        $("#result").text("中文输入：开始")
                },
                compositionend: function () {
//                        $("#result").text("中文输入：结束")
                    var url = $(this).attr('data-url');
                    url += '?name=' + $(this).val();
                    console.log($(this).val())
                    $.get(url, function (res) {
                        console.log(res)
                        var html = '<ul>';
                        if (res) {
                            for (var i = 0; i < res.length; i++) {
                                html += '<li>';
                                html += '<b>' + res[i].user_name + '</b>';
                                html += '<span style="display:inline-block;margin-left:5px">' + res[i].mobil_no + '</span>';
                                html += '</li>';
                            }
                        }
                        html += '</ul>';
                        $('.inputWrap1 .list').html(html)
                    })
                }
            })
        })
//        换肤
        $(document).on("click", ".skindetail li", function () {
            var $index = $(this).index();
            if ($index == 0) {
                $('.page-index').removeClass("skin-blue");
                $('.page-index').removeClass("skin-green");
                renderChart(['#5091cb', '#d9e3eb']);
            } else if ($index == 1) {
                $('.page-index').addClass("skin-blue");
                $('.page-index').removeClass("skin-green");
                renderChart(['#5091cb', '#d9e3eb']);
            } else if ($index == 2) {
                $('.page-index').removeClass("skin-blue");
                $('.page-index').addClass("skin-green");
                renderChart(['#0dae95', '#d9e3eb']);
            }
        });
        if ($("#skin").hasClass("skin-green")) {
            renderChart(['#0dae95', '#d9e3eb']);
        } else {
            renderChart(['#5091cb', '#d9e3eb']);
        }
        //工作计划
        function renderChart(skin) {
            var url = $('#echartsUrl').val();
            $.get(url, function (res) {
                console.log(res)
                var myChart = echarts.init(document.getElementById('echart1'));
                option = {
                    tooltip: {
                        trigger: 'item',
                        //			        formatter: "{a} <br/>{b}: {c} ({d}%)"
                    },
                    color: skin,
                    legend: {
                        orient: 'vertical',
                        x: '210',
                        y: "bottom",
                        itemWidth: 7,
                        itemHeight: 7,
                        data: [{name: '已完成', icon: "circle"}, {name: '未完成', icon: "circle"}],
                    },
                    series: [
                        {
                            name: '本月工作计划',
                            type: 'pie',
                            radius: ['50%', '65%'],
                            avoidLabelOverlap: false,
                            startAngle: 140,
                            itemStyle: {
                                borderWidth: 5
                            },
                            label: {
                                normal: {
                                    show: true,
                                    position: 'outside',
                                    formatter: '{b}\n（{c}件）',
                                    color: "#666",
                                    fontSize: 12,
                                    align: 'center',
                                },
                                emphasis: {
                                    show: true,
                                    textStyle: {
                                        fontSize: '12',
                                        fontWeight: 'bold'
                                    }
                                }
                            },
                            labelLine: {
                                normal: {
                                    show: true,
                                    lineStyle: {
                                        color: "#666"
                                    }
                                }
                            },
                            data: res
                        }
                    ]
                };
                myChart.setOption(option);
            })
        }

        var myCalendar = new SimpleCalendar('#container');
        var options = {
            timeRange: {
                startYear: 2018,
                endYear: 2049
            },
        }
        myCalendar.updateSize('100%', '190px'); //
        myCalendar.showFestival(false); //国际节日
        myCalendar.showLunarCalendar(false); //阴历日期
        myCalendar.showHoliday(false); //假期
        myCalendar.showSolarTerm(false); //二十四节气
        //			myCalendar.timeRange(2018,2020);

        $('#container .day').on('click', function () {
            //日历点击事件
            var year = $('.sc-select-year').val();
            var day = $(this).text();
        })
    })



    //修改个人信息
    $(document).on("click", ".setting", function () {
        var document_w = $(window).width();
        var document_h = $(window).height();
        var layer_w = '800';
        var layer_h = '430';
        var w = (document_w - layer_w) / 2;
        var h = (document_h - layer_h) / 2;
        layer.open({
            type: 2,
            shadeClose: true,
            anim: 0,
            title: "账户管理",
            area: [layer_w + 'px', layer_h + 'px'], //宽高
            content: ['accountInfo.html', 'auto'],
            success: function (layero, index) {
                var body = layer.getChildFrame('body', index);
            },
            end: function () {
            }
        });
    });
}
function getTime() {
    var myDate = new Date();
    var year = myDate.getFullYear();
    var month = myDate.getMonth() + 1;
    var date = myDate.getDate();
    var dayArray = new Array(7);
    dayArray[0] = "星期日";
    dayArray[1] = "星期一";
    dayArray[2] = "星期二";
    dayArray[3] = "星期三";
    dayArray[4] = "星期四";
    dayArray[5] = "星期五";
    dayArray[6] = "星期六";
    var day1 = myDate.getDay();
    var day = dayArray[day1];
    var hour = myDate.getHours();
    var minute = myDate.getMinutes();
    var second = myDate.getSeconds();
    var min = checkTime(minute);
    var sec = checkTime(second);
    var time1 = year + "-" + month + "-" + date;
    var time2 = hour + ":" + min;
//    var time2 = hour + ":" + min + ":" + sec;
    $('.date').text(time1);
    $('.time2').text(time2);
    var start = $('.time2').text().indexOf(':');
    if ($('.time2').text().substring(0, start) < 13) {
        $('.en-time').text('AM');
    } else {
        $('.en-time').text('PM');
    }
}
function checkTime(i) {
    if (i < 10) {
        i = "0" + i;
    }
    return i;
}

//获取待办流程数量
function breakFlowCount() {
    var url = $('#getFlowCountUrl').val();
    $.get(url, function (res) {
        console.log(res)
        $('.box32 span').text(res);
        $('.section7 ul li').first().find('span').text(res)
    })
}

//弹出定时提醒页面
function getRemindView() {
    var url = $('#getRemindViewUrl').val();
    $.get(url, function (res) {
        console.log(res);
        if (res != '') {
            var html = '<p style="margin:30px auto 10px;"><b style="display: block; text-align: center;color:#ff3c00;font-weight:normal;font-size: 17px;"><i class="iconfont" style="color:#ff3c00;font-size: 19px;margin-right: 6px;">&#xe6c6;</i>日程提醒</b></p>';
            for (var i = 0; i < res.length; i++) {
                html += '<div style="padding:10px 30px;">';
                html += '<p style="font-size: 14px;line-height:23px;">您设置的<span style="color:#ff3c00;margin: 0 6px;">' + res[i].remind_time + '</span>' + res[i].title + '即将开始，请您做好准备！</p>';
                html += '</div>';
            }
            layer.open({
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                area: ['420px', '240px'], //宽高
                content: html
            });
        }

    })
}